package cn.kgc.controller;

import cn.kgc.pojo.Repair;
import cn.kgc.service.RepairService;
import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

@Controller
public class RepairController {

    @Resource
    private RepairService repairService;
    @RequestMapping(value = "/queryRepair")
    @ResponseBody
    public String queryRepairByDeviceId(int deviceId){
        return JSON.toJSONString(repairService.queryRepairByDeviceId(deviceId));
    }

    @RequestMapping(value = "/insert")
    @ResponseBody
    public String insertRecord(Repair repair){
        repair.setRepairTime(new Date());

        boolean flag=repairService.insertRepair(repair);

        return Boolean.toString(flag);
    }
}
